﻿Public Class CreateStu
    Private Sub CreateStu_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        clear()
    End Sub

    Private Sub clear()
        Me.lblIsActiveValue.Tag = Nothing
        Me.lblGenderValue.Tag = Nothing
        Me.txtAge.Text = Nothing
        Me.txtCertId.Text = Nothing
        Me.txtLoginName.Text = Nothing
        Me.txtName.Text = Nothing
        Me.txtPwd.Text = Nothing
        chkIsActive.Checked = False
        rbFemale.Checked = False
        rbMale.Checked = False
    End Sub

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        Dim age As Integer = Integer.Parse(Me.txtAge.Text)
        Dim certId As String = Me.txtCertId.Text
        Dim loginName As String = Me.txtLoginName.Text
        Dim name As String = Me.txtName.Text
        Dim pwd As String = Me.txtPwd.Text

        Dim isActive As Integer = 0
        If Me.chkIsActive.Checked Then
            isActive = 1
        End If
        Dim gender As Integer
        If rbMale.Checked Then
            gender = 0
        ElseIf rbFemale.Checked Then
            gender = 1
        Else
            gender = 0
        End If
        Dim returned = Me.StudentTableAdapter1.Insert(loginName, pwd, name, age, certId, isActive, Date.Now(), Date.Now(), gender)
        If returned > 0 Then
            System.Windows.Forms.MessageBox.Show("创建学生成功！")
            clear()
            Me.Close()
            'Me.StudentTableAdapter1.FillById(Me.ExamDataSet.student, returned)
        Else
            System.Windows.Forms.MessageBox.Show("创建学生失败请检查数据！")
        End If
    End Sub
End Class